/*------------------------------------------------------------------------------
    JS Document (https://developer.mozilla.org/en/JavaScript)

    project:    majx JavaScript Library http://code.google.com/p/majx-js/
    license:    New BSD License http://www.opensource.org/licenses/bsd-license.php
    author:     Copyright (c) 2009
                Yves Van Goethem and Vincent Valentin
                All rights reserved.

    module:     majx core
    summary:    INIT
                majx.set
----------------------------------------------------------------------------- */

/* =INIT
----------------------------------------------------------------------------- */
(function(){
    if (typeof majx == 'undefined') {
        majx = {};
        majx.init = function(){
            if (!majx.config) {
                majx.config = {};
            }
        }();
    }
}());


/* =majx.set
----------------------------------------------------------------------------- */
majx.set = function() {
    // this is inspired by jQuery.extend() , thanks guys
    var target  = arguments[0] || {};
    var options = null;
    var length  = arguments.length;
    var i = 1;

    if ( length == i ) {
        target = majx.config;
        --i;
    }

    for ( ; i < length; i++ ) {
        if ( (options = arguments[ i ]) != null ) {
            for ( var name in options ) {
                var src  = target[ name ];
                var copy = options[ name ];

                if ( target === copy ) {
                    continue;
                }

                else if ( copy !== undefined ) {
                    target[ name ] = copy;
                }
            }
        }
    }
    majx.config = target;
};